package com.shen.thread.state;

//线程分为用户线程和守护线程
public class TestDaemon {
    public static void main(String[] args) {

        Thread thread = new Thread(new God());
        thread.setDaemon(true);//设置为守护线程
        thread.start();
        new Thread(new You()).start();

    }
}

class God implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("神永生");
        }
    }
}

class You implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("你活着");
        }
        System.out.println("世界再见===============");
    }
}
